package collection;


import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

//遍历/迭代器
public class ItratorDemo {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<>();
        c.add("one");
        c.add("#");
        c.add("two");
        c.add("#");
        c.add("three");
        c.add("#");
        c.add("four");
        c.add("#");
        c.add("five");
        System.out.println(c);

        Iterator<String> it = c.iterator();
        while (it.hasNext()){
            String s = it.next();
            System.out.println(s);
            if("#".equals(s)){
                //c.remove(s);
                it.remove();
            }
        }
        System.out.println(c);
        for(String str : c){
            System.out.println(str);
        }


    }
}
